package 笔试.爱奇艺;

import java.util.*;

/**
 * 爱奇艺笔试第二题：避免洪水泛滥，同lc1488
 */
public class Pool {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String[] split = str.replace("[","").replace("]","").split(",");
        int[] rains = new int[split.length];
        for(int i=0;i<split.length;i++){
           rains[i] = Integer.valueOf(split[i]);
        }
        //System.out.println(Arrays.toString(rains));
        //发生洪水输出空数组，不发生
        boolean flag = false;
        int[] ans = new int[rains.length];
        Arrays.fill(ans,1);
        Map<Integer,Integer> water = new HashMap<>();
        TreeSet<Integer> zero = new TreeSet<>();
        for(int i=0;i<rains.length;i++){
            int rain = rains[i];
            if(rain==0){ //晴天存下标
                zero.add(i);
                continue;
            }
            if(water.containsKey(rain)){ //下雨天，且这个湖泊已经下过雨
                Integer r = zero.higher(water.get(rain));//找到之前一次下雨的下标所对应的下一个晴天下标
                if(r == null){ //没有满足要求的晴天的下标，返回空数组
                    flag = true;
                    break;
                }
                ans[r]=rain;  //清空的湖泊下标
                zero.remove(r); //移除使用过的晴天
            }
            water.put(rain,i); //存放下雨的h湖泊
            ans[i]=-1; //下雨不能操作
        }
        if(flag){
            System.out.println(new int[0]);
        }else{
            System.out.println(Arrays.toString(ans));
        }


    }
}
